package com.zmj.service.impl;

import com.zmj.comon.HttpRemoteClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

public class TsSearchServiceImpl {

    private Logger log = LoggerFactory.getLogger(TsSearchServiceImpl.class);

    @Autowired
    private HttpRemoteClient httpRemoteClient;


//    public List<SingleNodeResult> queryTSData(String namespace, List<SingleNodeResult> singleNodeResults, String interfaceUrl, QueryDetailCondition detail) {
//        log.info("pressureReport：namespace={}，interfaceUrl={}", namespace, interfaceUrl);
//        if (CollectionUtils.isEmpty(singleNodeResults)) {
//            log.warn("数据点为空");
//            return new ArrayList<>();
//        }
//
//        //构建查询参数
//        List<RequestCodeCondition> nodes = new ArrayList<>();
//        singleNodeResults.forEach(singleNodeResult ->
//                {
//                    RequestCodeCondition codeCondition = new RequestCodeCondition();
//                    codeCondition.setSysCode(singleNodeResult.getSysCode());
//                    codeCondition.setDeviceCode(singleNodeResult.getDeviceCode());
//                    codeCondition.setDataID(singleNodeResult.getDataID());
//                    codeCondition.setNameSpace(namespace);
//                    nodes.add(codeCondition);
//                }
//
//        );
//        //使用数据点获取ts服务获取数据
//        QueryCondition condition = new QueryCondition();
//        condition.setNodes(nodes);
//        if (null == detail.getStartTime() || null == detail.getEndTime()) {
//            log.warn("查询参数的起止时间配置结果为空");
//            return null;
//        }
//        condition.setDetail(detail);
//
//        ResponseDTO<List<SingleNodeResult>> singleNodeResultList = httpRemoteClient.postForObject(RemoteUrlConfig.tsServer + interfaceUrl, JSON.toJSONString(condition), new TypeReference<ResponseDTO<List<SingleNodeResult>>>() {
//        }, null);
//        log.info("TsSearchServiceImpl(),resultCode={},resultMsg={}", singleNodeResultList.getCode(), singleNodeResultList.getMsg());
//        //在此对label进行拼接操作  label = sysCode + deviceCode + dataID
//        List<SingleNodeResult> list = singleNodeResultList.getData();
//        if (null != list) {
//            for (SingleNodeResult singleNodeResult : list) {
//                List<TsData> data = singleNodeResult.getData();
//                //对data进行遍历
//                if (null != data) {
//                    for (TsData datum : data) {
//                        datum.setLabel(LabelDataUtil.getLabel(singleNodeResult.getSysCode(), singleNodeResult.getDeviceCode(), singleNodeResult.getDataID()));
//                    }
//                }
//            }
//            return list;
//        }
//        return new ArrayList<>();
//    }


//    public boolean manualAnalyse(ManualAnalyseDTO manual) {
//        //调用python进行手动计算功能
//        ResponseDTO<String> responseDTO = null;
//        try {
//            responseDTO = httpRemoteClient.postForObject(RemoteUrlConfig.pythonServer + Constants.PYTHON_MANUALANALYSE, JSON.toJSONString(manual), new TypeReference<ResponseDTO<String>>() {
//            }, null);
//        } catch (Exception error) {
//            log.error("调用python手动计算功能出错，error", error);
//        }
//        log.info("调用python手动计算功能为，manual={},responseDTO={}", manual, responseDTO);
//        if (null == responseDTO || Constants.PYTHON_SUCCESS.intValue() != responseDTO.getCode()) {
//            log.error("调用python手动计算出错");
//            return false;
//        }
//        return true;
//    }


}
